/**
 * Created by heshufen on 20/6/27.
 */

/**
 *
 * @param url
 * @param width
 * @param height
 * @returns {*}
 */
export const disposeImageUrl = (url, {width, height}, quality, resizeModeValue = 1) => {

    if (url.match(/\?/)) //有参数的一律不处理
    {
        return url;
    }

    let density = 2;

    if (quality) {
        density = density * quality;
    }

    width = Math.floor(width);
    height = Math.floor(height);

    if (height && width) {
        return url + `?imageView2/${resizeModeValue}/w/${parseInt(width * density)}/h/${parseInt(height * density)}`;
    }

    url += '?imageView2/1';

    if (width) {
        url += `/w/${width * density}`;
    } else if (height) {
        url += `/h/${height * density}`;
    }

    return url;
};
